home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  1003 b   |  [TEXT/ttxt]

  1. Subject:     Re: 
  2. Sent:        6/11/96 12:20 PM
  3. Received:    6/11/96 12:31 PM
  4. From:        Serge Froment, sfroment@odyssee.net
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. >If you use a TextReader the code would look something like this:
  9. >  FW_CMemoryReader* reader = FW_NEW(FW_CMemoryReader, (bufferPtr,
  10. >numberOfBytes));
  11. >  while (reader->GetPosition() < reader->GetByteCount())
  12. >  {
  13. >    FW_LChar ch = reader->GetCharacterAndAdvance();
  14. >    if (ch == chTab) ...
  15. >  }
  16.  
  17. Mary,
  18.  
  19. If I want to copy from a text reader to a string, would the following loop
  20. be both OK and efficient?
  21.  
  22. FW_CString string;
  23. while (reader->GetPosition() < reader->GetByteCount)
  24. {
  25.         FW_LChar ch = reader->GetCharacterAndAdvance();
  26.         string.Append(ch);
  27.         if (ch == chTab || ch == chReturn)
  28.                 break;
  29. }
  30.  
  31. Also, why do you allocate the reader with the FW_NEW operator instead of
  32. allocating it on the stack?
  33.  
  34. Serge
  35.  
  36.